#                                               -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.

AC_PREREQ([2.65])
AC_INIT([svn-graph-branches], [0.10], [dolmen@cpan.org])
AM_INIT_AUTOMAKE([foreign check-news])

# --without-java
AC_ARG_WITH([java],
  [AS_HELP_STRING([--with-java], [use the JRE to process XSLT])],
  [],
  [with_java=yes])

# --without-xsltproc
AC_ARG_WITH([xsltproc],
  [AS_HELP_STRING([--with-xsltproc], [use xsltproc to process XSLT])],
  [],
  [with_xsltproc=yes])


# Checks for programs.
AC_PATH_PROG([SUBVERSION], [svn], [svn])
AC_PATH_PROG([GRAPHVIZ_DOT], [dot], [dot])

AS_IF([test "x${with_xsltproc}" != xno ],
  [AC_CHECK_PROG([XSLTPROC], [xsltproc], [xsltproc])
  AS_IF([test "x${XSLTPROC}" = xno], [with_xsltproc=no])
])
AS_IF([test "x${with_java}" != xno ],
dnl  [AC_CHECK_PROGS([JAVA], [java jre], [java])])
  [AC_PROG_JAVA
  AC_PROG_JAVAC
  AS_IF([test "x${JAVA}" = xno], [with_java=no])
])

# Decide which method to use
AS_IF([test "x${with_java}" = xyes], [xslt_method=java],
  [test "x${with_xsltproc}" = xyes], [xslt_method=xsltproc],
  [AC_MSG_ERROR([No supported method available for running $PACKAGE_NAME: install either xsltproc or Java.])])

AM_CONDITIONAL([WITH_JAVA], [test x$xslt_method = xjava])

AC_MSG_NOTICE([selected '$xslt_method' XSLT processor])

AC_PROG_INSTALL
dnl AC_CHECK_PROG([ANT], [ant], [ant])

AC_CONFIG_FILES([Makefile
                 bin/svn-graph-branches:bin/svn-graph-branches.${xslt_method}.in])
AC_OUTPUT
